﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using QuantitativeInvestment.Bean;
using System.Reflection;
namespace QuantitativeInvestment.StockPool
{
    class StockPool
    {

        public Dictionary<string,Parameter> paraList;
        public string poolName;
        public StockPool()
        {

            this.paraList = new Dictionary<string, Parameter>();

        
        }


        public virtual List<TradingStock> getStocks(string tradingDate)
        {
            return null;
        }

        public static StockPool createStockPoolByName(String name)
        {
            StockPool pool = null;
            DataSet ds = new DataSet();
            ds.ReadXml(System.Windows.Forms.Application.StartupPath + "/Config" + "/StockPools.xml");
            DataRow[] rows = ds.Tables["stockpool"].Select("name='" + name + "'");
            if (rows.Length > 0)
            {
                Assembly a = Assembly.GetExecutingAssembly();
                pool = (StockPool)a.CreateInstance(rows[0]["objectName"].ToString());
            }

            return pool;
        }

        public static List<string> getStockPoolNameList()
        {
            DataSet ds = new DataSet();
            ds.ReadXml(System.Windows.Forms.Application.StartupPath + "/Config" + "/StockPools.xml");
            List<string> poolNameList = new List<string>();
            foreach (DataRow row in ds.Tables["stockpool"].Rows)
            {
                poolNameList.Add(row["name"].ToString());
            }

            return poolNameList;
        }

    }
}
